#!/bin/sh
# usage: split_file.sh splitted_file_name split_num
:<<COMMENT
  first caculate the total num of file
  second split file by total_num / num_per_file
COMMENT

linenum=`wc -l $1 |awk '{print $1}'`
echo $linenum
echo $2
num_begin=1
file_num=1
line=`expr $linenum / $2`
echo $line
while [ $num_begin -lt $linenum ]
  do
    num_end=`expr $num_begin + $line`
    sed -n "${num_begin}, ${num_end}p" $1 > uid_$file_num
    #python preload_indexN.py -i uid_$file_num -o uid_${file_num}.log -t &
    num_begin=`expr $num_end + 1`
    file_num=`expr $file_num + 1`
  done 
